package org.ccunix.eshop.service;
import org.ccunix.eshop.dao.MemberlevelDAO;
public class MemberLevelservice {
	public int add(String levelName, String favourable){
		int int_favourable = Integer.parseInt(favourable);
		MemberlevelDAO memberlevelDAO = new MemberlevelDAO();
		try{
			int row = memberlevelDAO.insert(levelName,int_favourable);
			 return row;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return 0;
	}
	public int update(String levelName, String favourable, String id) {
		int int_favourable = Integer.parseInt(favourable);
		int int_id = Integer.parseInt(id);

		MemberlevelDAO memberlevelDAO = new MemberlevelDAO();
		try{
			int row = memberlevelDAO.update(levelName,int_favourable,int_id);
			 return row;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return 0;
	}
	public int detele(String id) {
		
		int int_id = Integer.parseInt(id);

		MemberlevelDAO memberlevelDAO = new MemberlevelDAO();
		try{
			int row = memberlevelDAO.delete(int_id);
			 return row;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return 0;
	}
	public void query() {
		MemberlevelDAO memberlevelDAO = new MemberlevelDAO();
		try {
			memberlevelDAO.query();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
